#! /bin/bash
#更新系统 以及安装make gcc 
apt update -y

#启动soft 服务端
sleep 1
cd softserver 
chmod 777 vpnserver
sudo ./vpnserver start 
cd ..
#设置网卡ip
sleep 2 
ifconfig tap_pi 192.168.10.1
sudo echo -e "softehter 服务段启动成功"
sudo echo -e "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
sudo sysctl -p
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo echo -e "ip内核转发成功共享上网成功"
sleep 3
#安装dhcp 
apt install isc-dhcp-server isc-dhcp-server-ldap -y
echo -e "dhcpd 安装成功"
sleep 3
rm -rf /etc/dhcp/dhcpd.conf
touch /etc/dhcp/dhcpd.conf
echo -e "subnet 192.168.10.0 netmask 255.255.255.0 {
  range 192.168.10.50 192.168.10.200;
  option subnet-mask 255.255.255.0;
  option routers 192.168.10.1;

}
option domain-name-servers 8.8.8.8;
default-lease-time 6000000;
max-lease-time 7200000;"  >>/etc/dhcp/dhcpd.conf
sleep 3
service isc-dhcp-server start
echo -e "dhcp服务器启动成功"

sleep 3
apt  install nginx -y
echo -e "nginx安装成功"
systemctl stop nginx
echo -e  "停止服务成功"
sleep 3 
rm -rf /etc/nginx/nginx.conf
echo -e "删除文件成功"
sleep 3 
cp nginx.conf /etc/nginx
echo -e "配置文件生效"
sleep 3
systemctl start nginx
echo -e "服务器架设成功，请验收 我是笨蛋刘晓陆"   
